using System;

namespace IQIGame.Onigao.GamePlay
{
    public static class ShareLevelMathUtil
    {
        /// <summary>
        /// 骤然下降的曲线
        /// </summary>
        /// <param name="x">主要的变化参数，大致上x从 0 ~ (minResult - maxResult)的过程中，y会骤然下降，然后平缓趋近于0</param>
        /// <param name="xRange">x值变化范围，x为0时y最大，x为xRange时y为0</param>
        /// <param name="minResult">返回值最小值</param>
        /// <param name="maxResult">返回值最大值</param>
        /// <returns>y + min</returns>
        public static float PlummetCurve(float x, int xRange, float minResult, float maxResult)
        {
            float delta;
            if (x > xRange)
            {
                delta = 0;
            }
            else
            {
                delta = (maxResult - minResult) * (1 - x / xRange) * (float)Math.Exp(-x / 0.5f);
            }
            return delta + minResult;
        }
    }
}
